using System;
using System.Collections.Generic;
using System.Text;

namespace PersistenceObject.Framework.Expressions
{
    public class TextField : FieldAdapter
    {
        public TextField(string name) : base(name)
        {
        }

        public TextField(string name, FieldAdapter basefield) : base(name, basefield)
        {
        }

        public TextField As(string name)
        {
            return new TextField(string.Format("{0} {1}", this.Name, name), this);
        }

        public TextField At(Table table)
        {
            String[] tempArr = this.Name.Split('.');
            if (tempArr.Length > 1)
            {
                this.name = tempArr[1];
            }
            string alias = table.Alias;
            if (string.IsNullOrEmpty(alias))
            {
                alias = table.Name;
            }
            return new TextField(string.Format("{0}.{1}", alias, this.Name), this);
        }

        public FieldValue Set(string value)
        {
            return new FieldValue(this.Name, value);
        }

    }
}

